package com.pxxy.app_knowledge;

import android.os.Bundle;
import android.os.Environment;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.MediaController;
import android.widget.VideoView;

import com.pxxy.lib_common.base.BaseActivity;
import com.pxxy.lib_common.customview.CustomTitleView;
import com.pxxy.security512.R;

public class VideoScienceActivity extends BaseActivity {
    private CustomTitleView customTitleView;
    private VideoView videoView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public int initLayout() {
        return R.layout.activity_video_science;
    }

    @Override
    public void initView() {
        super.initView();
        customTitleView=findViewById(R.id.activity_knowledge_video_customtitle);//找到title的id
        videoView=findViewById(R.id.videoView);//找到视频的控件
    }

    @Override
    public void initEvent() {
        super.initEvent();
        //设置back键的监听
        customTitleView.setLeftImageButtonListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        //加载指定的视频文件
        String path = Environment.getExternalStorageDirectory().getPath()+"/VID20181201153336.mp4";
        videoView.setVideoPath(path);

        //创建MediaController对象
        MediaController mediaController = new MediaController(this);

        //VideoView与MediaController建立关联
        videoView.setMediaController(mediaController);

        //让VideoView获取焦点
        videoView.requestFocus();
    }
}
